package com.shixi.shixitraining.shixitraining.ui.tabhome.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.shixi.shixitraining.shixitraining.R;
import com.shixi.shixitraining.shixitraining.base.TabhostBaseFragment;
import com.shixi.shixitraining.shixitraining.ui.tabhome.entity.AuthenBean;
import com.shixi.shixitraining.shixitraining.view.recycleview.BaseAdapter;
import com.shixi.shixitraining.shixitraining.view.recycleview.BaseRecycleHolder;

import java.util.List;

/**
 * Created by shenyan on 2018/8/15.
 */

public class CourseOutlineFragment extends TabhostBaseFragment {


    @Override
    protected int getlayoutId() {
        return R.layout.fragment_course_outline;
    }

    @Override
    protected void initPager() {
        Bundle arguments = getArguments();
        if (arguments!=null){
            AuthenBean mData = (AuthenBean) arguments.getSerializable("bean");
            AuthenBean.DataBean data = mData.getData();
            List<AuthenBean.DataBean.CurriculumBean>   curriculumData = data.getCurriculum();

            RecyclerView coureseRcview = (RecyclerView) mContentView.findViewById(R.id.course_rcview);

            LinearLayoutManager manager=new LinearLayoutManager(getContext());
            manager.setOrientation(LinearLayoutManager.VERTICAL);
            coureseRcview.setLayoutManager(manager);

            CourseOutlineAdapter  adapter=new CourseOutlineAdapter(getContext(),curriculumData);
            coureseRcview.setAdapter(adapter);

        }


    }



    class  CourseOutlineAdapter  extends BaseAdapter<AuthenBean.DataBean.CurriculumBean> {


        public   CourseOutlineAdapter(Context context, List<AuthenBean.DataBean.CurriculumBean> data) {
            super(context, data);
        }


        @Override
        public void convert(BaseRecycleHolder holder, AuthenBean.DataBean.CurriculumBean item, int position) {

            holder.setText(R.id.tv_course_title,item.getTitle());
            holder.setText(R.id.tv_course_content,item.getContent());

        }

        @Override
        protected int getLayoutId(int viewType) {
            return R.layout.adapter_course;
        }


    }
}
